const p=31079; //prime number which is close to size of hash-table

procedure count();

var
	j, kk : longint; 
	c, i : int64; 
	f : boolean;
	
begin
	i := 256;
	while true do begin
		c := i;
		f := true;
		kk := p - 2;
		for j := 2 to kk do begin
			c := (c * i) mod p;
			if c = 1 then begin
				f := false;
				break;
			end;
		end;
		if f then begin
			write(i);
			halt(0);
		end;
		inc(i);
	end;
end;

function hash(s : string) : int64;

var 
	i, ls : longint; 
	c : int64;
	
begin
	result := 0;
	c := 1;
	ls := length(s);
	for i := 1 to ls do begin
		c := (c * x) mod p;
		inc(result, (ord(s[i]) * c) mod p);
		result := result mod p;
	end;
end;

procedure find();

var
	i, j, kk, cur : longint;
	f : boolean;

begin
	i := high(a);
	cur := 0;
	while true do begin
		kk := trunc(sqrt(i));
		f := true;
		for j := 2 to kk do
			if i mod j = 0 then begin
				f := false;
				break;
			end;
		inc(cur, byte(f));
		if cur = 4 then begin
			write(i);
			halt(0);
		end;
		inc(i);
	end;
end;